<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="vue1026.js"></script>
    <script src="vue-router-0.7.3.js"></script>
</head>
<body>

    <div id="app">
        <a href="#" v-link="{path:'/login'}">登入</a>
        <a href="#" v-link="{path:'/register/200'}">注册</a>
        <br>
        <router-view></router-view>
    </div>

    <script>
        //定义组件
        var App = Vue.extend({});
        //定义组件 1
        var register = Vue.extend({
            template:'<h1>注册{{id}}</h1>',
            data:function(){
                return {
                    id:0
                }
            },
            created:function(){
                this.id = this.$route.params.id;
            }
        })
        //定义组件 1
        var login = Vue.extend({
            template:'<h1>登入</h1>',
        })
    //实例化 Vue.组件
    var router = new VueRouter();

        //定义路由规则 
        //它是一个map
    router.map({
        'login':{
            component:login
        },
        'register/:id':{
            component:register
        }
    });
    //路由生效
    router.start(App,'#app');
        
    //默认显示的组件
    router.redirect({'/':'/login'});
    </script>

</body>
</html>